package io.dcloud.uniplugin;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.bytedance.sdk.openadsdk.TTAdConfig;
import com.bytedance.sdk.openadsdk.TTAdSdk;

import io.dcloud.feature.uniapp.UniAppHookProxy;


public class AdMob_AppProxy implements UniAppHookProxy {
    private static final String TAG = "testAdMob";

    @Override
    public void onCreate(Application application) {
        //可写初始化触发逻辑
        //强烈建议在应用对应的Application#onCreate()方法中调用，避免出现content为null的异常
        // TTAdsdk.init仅进行初始化,不会获取个人信息,如果要展示广告,需要再调用TTAdSdk.start方法
        TTAdSdk.init(application, buildConfig());
        //setp1.2：启动SDK
        TTAdSdk.start(new TTAdSdk.Callback() {
            @Override
            public void success() {
                Log.i(TAG, "success: " + TTAdSdk.isSdkReady());
            }

            @Override
            public void fail(int code, String msg) {
                Log.i(TAG, "fail:  code = " + code + " msg = " + msg);
            }


        });
    }

    private static TTAdConfig buildConfig() {
        return new TTAdConfig.Builder()
                .appId("5619429")//应用ID
                .useMediation(true)//开启聚合功能，默认false
                .supportMultiProcess(true)//开启多进程
                .build();
    }

    @Override
    public void onSubProcessCreate(Application application) {
        //子进程初始化回调
    }
}
